package ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import ssm.service.OrderService;

import javax.servlet.http.HttpSession;
import java.text.ParseException;

@Controller
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 获取所有订单信息，返回订单页
     * @param session
     * @return
     * @throws ParseException
     */
    @RequestMapping("/order")
    public String cart(HttpSession session) throws ParseException {
        orderService.getAllOrderBean(session);
        return "pages/order/order";
    }

    /**
     * 结账并清空购物车
     * @param session
     * @return
     * @throws ParseException
     */
    @RequestMapping("/checkout")
    public String checkout(HttpSession session) throws ParseException {
        orderService.checkout(session);
        return "pages/cart/checkout";
    }
}
